<?php
/**
+--------------------------------------------------------------
 * User: maqun
+--------------------------------------------------------------
 * Date: 2015/11/24
+--------------------------------------------------------------
 * Time: 21:44
+--------------------------------------------------------------
 *
+--------------------------------------------------------------
 */
 class ProblemTagModel extends BaseModel{
     protected $tableName = 'problem_tag'; //数据库表名

     /**
      * @param $tag
      * @return string
      *  通过问题标签获取问题id
      */
     public function getListByTag($tag){

         $res = $this->field('problemIdList')->where('id='.$tag)->limit(1)->select();
         if(!empty($res)){
             $ids = explode(",",$res[0]['problemIdList']);
             $id = array();
             foreach($ids as $k=>$v){
                 if(false !== strpos($v,'-')){
                     $temp = explode('-',$v);
                     for($i = $temp[0];$i<=$temp[1];$i++){
                         $id[] = $i;
                     }
                 }else{
                     $id[] = $v;
                 }
             }
             $return  = implode(',',$id);
         }else{
             $return = '';
         }
         return $return;
     }
 }